<%@ page contentType="text/html;charset=utf-8"%>
<%@page isELIgnored="false"%>
<%@ taglib prefix="cw" uri="/widget-tags"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>读卡</title>
		<cw:base />
		<script type="text/javascript"
			src="<s:url value='/resource/scripts/gridUtils.js'/>"></script>
		<script type="text/javascript"
			src="<s:url value='/resource/scripts/gridException.js'/>"></script>
		<script type="text/javascript"
			src="<s:url value='/resource/scripts/formUtils.js'/>"></script>
		<script type="text/javascript"
			src="<s:url value='/resource/scripts/storeUtils.js'/>"></script>
		<script type="text/javascript"
			src="<s:url value='/resource/scripts/utils.js'/>"></script>
		<script type="text/javascript"><!--
			function read(){
				var cardutil =document.getElementById("cardutilid");
				if(!cardutil){
					Ext.MessageBox.alert('提示', '请先安装读卡程序!');
					return;
				}
				var flag =cardutil.ReadCardNO(1,'000000');
				if(flag !=0){
					Ext.MessageBox.alert('提示', cardutil.errMsg);
					return;
				}
				
				var baz801 = '';//省卡号
				var baz805 = '';//省个人识别码
				//var cardNO = '1111111111111111|                                ';
				var cardNO = cardutil.cardNO.toString().trim();
				try {
						readCard(cardNO);
					
					} catch (e) {
					 // alert(e.name + ": " + e.message);
					 if(e.value == undefined){
					 	 if(cardNO.length!=16){
					 	 	var cardNOs= new Array(); //定义一数组
					    	cardNOs=cardNO.split("|"); //字符分割      
						 	if(cardNOs[0].length == 16){
						 		cardNO = cardNOs[0];
						 		Ext.getCmp('personSelect_aac001').setValue(cardNO);
								changeStoreParams('personSelect_aac001',{query:cardNO},true);
								Ext.getCmp('personSelect_aac001').focus();	
						 	}
						 	else if(cardNOs[0].length == 32){
						 		cardNO = cardNOs[1].substr(0,12);
						 		baz801 = cardNOs[0];
						 		baz805 = cardNOs[1].substr(0,12);
						 		//老卡注销，记录新卡卡号		
							 	 Yzsb.util.request(
									'${pageContext.request.contextPath}/commons/swipeProvCard.action',
									{baz801:baz801,baz805:baz805},
									'post',
									function(form,action){
									      cardNO = getFormValue(action, "baz805");
			                              Ext.getCmp('personSelect_aac001').setValue(cardNO);
										  changeStoreParams('personSelect_aac001',{query:cardNO},true);
										  Ext.getCmp('personSelect_aac001').focus();	
										}
									);
						 	}						 	
					 	 }
					 	 
					 }
					 else{
						 Ext.MessageBox.alert('错误', e.name + ": " + e.message);					
					 }
					}
				//readCard(cardNO);
				
				//if(cardNO.length==16){
				//	readCard(cardNO);
				//}else{
				//	var cardNOs= new Array(); //定义一数组
				//	cardNOs=cardNO.split("|"); //字符分割      
				//	var aaz500   = cardNOs[0].substr(0,16);//卡号
				//	var aaz500_s = cardNOs[1].substr(0,12);//省识别码(12位)
				//	//判断第二个是不是数字和字母
				//	if(/^[0-9a-zA-Z]*$/.test(aaz500_s)){
				//		readCard(aaz500_s);
				//	}else{
				//		readCard(aaz500);
				//	}
				//}
			}
			
	
		--></script>
 
	</head>

	<body>
		<object id="cardutilid"
			classid="clsid:D4851E8C-EAF0-4AE2-8F0E-AA82335556EF" width=0 height=0></object>
		<table>
			<tr>
				<td >
					<cw:button text="读社保卡" onclick="read()" ></cw:button>
				</td>
				
			</tr>
		</table>
		
		<cw:theme></cw:theme>
	</body>
	
</html>


